package com.example.source.redisson;

import lombok.extern.slf4j.Slf4j;
import org.redisson.api.RLock;
import org.redisson.api.RedissonClient;

public class LockTest {
    public static void main(String[] args) {
        RedissonClient redissonClient = RedissonManager.getRedisson();
        RLock lock = redissonClient.getLock("myLock");

        for (int i = 0; i < 5; i++) {
            lock.lock();
            try {
                System.out.printf("锁已获取:%d%n",i);
            } finally {
                lock.unlock();
            }
        }

        redissonClient.shutdown();
    }
}
